package com.usian.admin.controller;

import com.usian.admin.AdChannelControllerApi;
import com.usian.admin.AdSensitiveControllerApi;
import com.usian.admin.service.AdChannelService;
import com.usian.admin.service.AdSeneitiveService;
import com.usian.admin.service.WemediaNewsAutoScanService;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.dtos.SensitiveDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.admin.pojos.AdSensitive;
import com.usian.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/sensitive")
@Api(value = "敏感词模块",tags = "Sensitive",description = "敏感词管理API")
public class AdSensitiveController implements AdSensitiveControllerApi {

    @Autowired
    private AdSeneitiveService channelService;

    @Autowired
    private WemediaNewsAutoScanService wemediaNewsAutoScanService;

    @PostMapping("/list")
    @Override
    @ApiOperation(value = "敏感词查询",notes = "根据姓名模糊查")
    public ResponseResult findByNameAndPage(@RequestBody SensitiveDto dto){
        return channelService.findByNameAndPage(dto);
    }

    @Override
    @PostMapping("/save")
    @ApiOperation(value = "添加敏感词接口",notes = "接受json串")
    public ResponseResult save(@RequestBody AdSensitive channel) {
        return channelService.insert(channel);
    }

    @Override
    @PostMapping("/update")
    @ApiOperation(value = "修改敏感词信息接口",notes = "接受json串")
    public ResponseResult update(@RequestBody AdSensitive adChannel) {
        return channelService.update(adChannel);
    }

    @Override
    @GetMapping("/del/{id}")
    @ApiOperation(value = "删除敏感词接口",notes = "根据id删除")
    public ResponseResult deleteById(@PathVariable("id")Integer id) {
        return channelService.deleteById(id);
    }


    @GetMapping("/scan/{id}")
    public ResponseResult autoScanByMediaNewsId(@PathVariable("id")Integer id) {
        return wemediaNewsAutoScanService.autoScanByMediaNewsId(id);
    }



}